<template>
  <div v-if="formConfig">
    <proc-cloud-form v-if="formConfig.confKey==='startCloudForm'"
                     ref="actForm"
                     @submit="submitFormEvent"></proc-cloud-form>
    <div v-else>
      未找到有效的表单
    </div>
  </div>

</template>
<script>
import procCloudForm from "./procCloudForm.vue";

export default {
  name: "procMainForm",
  components: {procCloudForm},
  props: {
    isEdit: {
      type: [String, Boolean],
    },
    formConfig: {
      type: Object,
    },
    modelValue: {
      type: Object
    },
    formPropConfig: {
      type: Object,
    }

  },
  provide() {
    return {
      getFormConfig: () => {
        return this.formConfig;
      },
      getFormData: () => {
        return this.modelValue
      },
      getFormIsEdit: () => {
        return this.isEdit;
      },
      getFormPropConfig: () => {

        return this.formPropConfig || {};
      }
    }
  },

  data() {
    return {}
  },
  created() {

  },
  methods: {
    submit() {
      this.$refs.actForm.submit();
    },
    resetForm() {
      this.$refs.actForm.resetForm();
    },
    validate() {
      return this.$refs.actForm.validate();
    },
    getFormData() {
      return this.$refs.actForm.getFormData();
    },
    submitFormEvent(formData, done) {
      this.$emit("update:modelValue", formData, done)
      this.$emit("submit", formData, done)
    }
  }
}

</script>
<style scoped>

</style>
